﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Windows;

namespace Microsoft.Xna.Framework.Graphics
{
    /// <summary>
	/// Provides methods to retrieve and manipulate graphics adapters.
    /// </summary>
    public class GraphicsAdapter
    {
		static ReadOnlyCollection<GraphicsAdapter> pAdapterList;

		#region Properties
		/// <summary>
		/// Collection of available adapters on the system.
		/// </summary>
		public static ReadOnlyCollection<GraphicsAdapter> Adapters
		{
			get { return pAdapterList; }
		}

		/// <summary>
		/// Gets the current display mode.
		/// </summary>
		public DisplayMode CurrentDisplayMode
		{
			get
			{
				return new DisplayMode(
					(int)Application.Current.RootVisual.RenderSize.Width,
					(int)Application.Current.RootVisual.RenderSize.Height,
					SurfaceFormat.Color);
			}
		}

		/// <summary>
		/// Gets the default adapter.
		/// </summary>
        public static GraphicsAdapter DefaultAdapter
        {
			get { return pAdapterList[0]; }
        }

		/// <summary>
		/// Retrieves a string that contains the device name for a Microsoft Windows Graphics Device Interface (GDI).
		/// </summary>
		public string DeviceName
		{
			get { return "SilverLight"; }
		}

		/// <summary>
		/// Determines if this instance of GraphicsAdapter is the default adapter.
		/// </summary>
		public bool IsDefaultAdapter
		{
			get { return (this == pAdapterList[0]); }
		}

		/// <summary>
		/// Determines if the graphics adapter is in widescreen mode.
		/// </summary>
		public bool IsWideScreen
		{
			get { return (this.CurrentDisplayMode.AspectRatio <= 1.6000000238418579); }
		}

		/// <summary>
		/// Retrieves the handle of the monitor associated with the Microsoft Direct3D object.
		/// </summary>
		/// <remarks>Returns a dummy value.</remarks>
		public IntPtr MonitorHandle
		{
			get { return new IntPtr(); }
		}
		#endregion

		#region Constructor
		static GraphicsAdapter()
		{
			List<GraphicsAdapter> adapterList = new List<GraphicsAdapter>()
			{
				new GraphicsAdapter()
			};
			pAdapterList = new ReadOnlyCollection<GraphicsAdapter>(adapterList);
		}

		private GraphicsAdapter()
		{
		}
		#endregion

		#region Public Methods
		/// <summary>
		/// Tests to see if the adapter supports the requested profile.
		/// </summary>
		/// <param name="graphicsProfile">The graphics profile.</param>
		public bool IsProfileSupported(GraphicsProfile graphicsProfile)
		{
			return (graphicsProfile == GraphicsProfile.Reach);
		}

		/// <summary>
		/// Queries the adapter for support for the requested back buffer format.
		/// </summary>
		/// <param name="graphicsProfile">The graphics profile.</param>
		/// <param name="format">The requested surface data format.</param>
		/// <param name="depthFormat">The requested depth buffer format.</param>
		/// <param name="multiSampleCount">The requested number of multisampling locations.</param>
		/// <param name="selectedFormat">The best format the adapter supports for the requested surface data format.</param>
		/// <param name="selectedDepthFormat">The best format the adapter supports for the requested depth data format.</param>
		/// <param name="selectedMultiSampleCount">The best format the adapter supports for the requested number of multisampling locations.</param>
		public bool QueryBackBufferFormat(GraphicsProfile graphicsProfile, SurfaceFormat format, DepthFormat depthFormat, int multiSampleCount, out SurfaceFormat selectedFormat, out DepthFormat selectedDepthFormat, out int selectedMultiSampleCount)
		{
			throw new NotImplementedException();
		}

		/// <summary>
		/// Queries the adapter for support for the requested render target format.
		/// </summary>
		/// <param name="graphicsProfile"></param>
		/// <param name="format"></param>
		/// <param name="depthFormat"></param>
		/// <param name="multiSampleCount"></param>
		/// <param name="selectedFormat"></param>
		/// <param name="selectedDepthFormat"></param>
		/// <param name="selectedMultiSampleCount"></param>
		public bool QueryRenderTargetFormat(GraphicsProfile graphicsProfile, SurfaceFormat format, DepthFormat depthFormat, int multiSampleCount, out SurfaceFormat selectedFormat, out DepthFormat selectedDepthFormat, out int selectedMultiSampleCount)
		{
			throw new NotImplementedException();
		}
		#endregion
	}
}
